package com.xu.ai.chatclient.controller;

import com.alibaba.cloud.ai.dashscope.api.DashScopeApi;

import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xu.ai.chatclient.service.RestClientService;
import com.xu.ai.chatclient.util.AiRestUtil;

/**
 * ai rest request controller
 *
 * @author xuguan
 * @since 2025/10/17
 */
@RestController
@RequestMapping("/api/rest")
public class RestClientController {

	private final RestClientService restClientService;

	public RestClientController(RestClientService restClientService) {
		this.restClientService = restClientService;
	}

	@PostMapping(value = "/send")
	public DashScopeApi.ChatCompletion send(@ModelAttribute("model-uri") AiRestUtil.ModelUri modelUri,
			@ModelAttribute("async") boolean async, @RequestBody Object body) {
		return restClientService.send(modelUri, body, async);
	}

}
